From d80a8c31ac05f484615919ab1c3f1a6fd859a7ec Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Tue, 20 Feb 2007 23:54:42 +0000 Subject: [PATCH] hvm: Fix getvcpucontext to return the correct CR3 value. Signed-off-by: Keir Fraser --- xen/arch/x86/domctl.c | 30 ++++++++++++++++-------------- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 69e2259d7f..d8f78c6262 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -441,6 +441,10 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) XLAT_vcpu_guest_context(c.cmp, &v->arch.guest_context); #endif + c(flags &= ~(VGCF_i387_valid|VGCF_in_kernel)); + if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) ) + c(flags |= VGCF_i387_valid); + if ( is_hvm_vcpu(v) ) { if ( !IS_COMPAT(v->domain) ) @@ -464,24 +468,22 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) /* IOPL privileges are virtualised: merge back into returned eflags. */ BUG_ON((c(user_regs.eflags) & EF_IOPL) != 0); c(user_regs.eflags |= v->arch.iopl << 12); - } - c(flags &= ~(VGCF_i387_valid|VGCF_in_kernel)); - if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) ) - c(flags |= VGCF_i387_valid); - if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) ) - c(flags |= VGCF_in_kernel); - - if ( !IS_COMPAT(v->domain) ) - c.nat->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); + if ( !IS_COMPAT(v->domain) ) + c.nat->ctrlreg[3] = xen_pfn_to_cr3( + pagetable_get_pfn(v->arch.guest_table)); #ifdef CONFIG_COMPAT - else - { - l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table)); - c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e)); - } + else + { + l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table)); + c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e)); + } #endif + if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) ) + c(flags |= VGCF_in_kernel); + } + c(vm_assist = v->domain->vm_assist); #undef c } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 5613cdb333..0301781c18 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -696,7 +696,7 @@ static void vmx_store_cpu_guest_regs( { crs[0] = v->arch.hvm_vmx.cpu_shadow_cr0; crs[2] = v->arch.hvm_vmx.cpu_cr2; - crs[3] = __vmread(GUEST_CR3); + crs[3] = v->arch.hvm_vmx.cpu_cr3; crs[4] = v->arch.hvm_vmx.cpu_shadow_cr4; } -- 2.30.2